"""
進入爱逛卖家版
"""
import time

import yaml
from uiautomator2 import xpath

from page_object.guang_page import GuangPage
from page_object.login_page import LoginPage
from resource.path_info import *

"""
个人信息
"""
class PersonDetailPage(GuangPage):

    """
    修改namme
    """
    def modify_name(self, d):
        print("modify_name")
        before_name = d.xpath(person_detail_name_xpath).get_text()
        # edit name
        d.xpath(person_detail_name_xpath).click()
        d.xpath(person_detail_name_input_xpath).click()
        d(focused=True).send_keys(before_name+"update")
        d.xpath(person_detail_name_save_xpath).click()
        # check edit
        time.sleep(1)
        assert d.xpath(person_detail_name_xpath).get_text() == before_name+"update"
        # recovery
        d.xpath(person_detail_name_xpath).click()
        d.xpath(person_detail_name_input_xpath).click()
        d(focused=True).send_keys(before_name)
        d.xpath(person_detail_name_save_xpath).click()
        # check recovery
        time.sleep(1)
        assert d.xpath(person_detail_name_xpath).get_text() == before_name
        return self

    """
    修改header
    """
    def modify_header(self, d):
        print("modify_header")
        # edit header
        d.xpath(person_detail_header_xpath).click()
        d.xpath(to_take_photo_xpath).wait(timeout=3.0)
        d.xpath(to_take_photo_xpath).click()
        d.xpath(take_photo_xpath).click()
        d.xpath(pre_confirm_photo_xpath).wait(timeout=5.0)
        d.xpath(pre_confirm_photo_xpath).click()
        d.xpath(confirm_photo_xpath).click()
        time.sleep(2)
        d.press("back")
        time.sleep(1)
        d.press("back")
        return self
